package mc.support.web.action;

import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

/**
 * Created with IntelliJ IDEA. <br/>
 * Author: Francis Yun    <br/>
 * Date: 2014-04-21  <br/>
 */
public class WriteException extends IOException {

    private static final long serialVersionUID = 3586932013162203258L;
    private PrintWriter printWriter;
    private OutputStream outputStream;
    private Exception originalException;

    public WriteException(PrintWriter printWriter,
                          OutputStream outputStream,
                          Exception originalException) {
        this.printWriter = printWriter;
        this.outputStream = outputStream;
        this.originalException = originalException;
    }

    public PrintWriter getPrintWriter() {
        if ( null == printWriter && null != outputStream ) {
            printWriter = new PrintWriter( new OutputStreamWriter( outputStream ) );
        }
        return printWriter;
    }

    public void setPrintWriter(PrintWriter printWriter) {
        this.printWriter = printWriter;
    }

    public OutputStream getOutputStream() {
        return outputStream;
    }

    public void setOutputStream(OutputStream outputStream) {
        this.outputStream = outputStream;
    }

    public Exception getOriginalException() {
        return originalException;
    }

    public void setOriginalException(Exception originalException) {
        this.originalException = originalException;
    }
}
